package com.monitor.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.monitor.system.domain.vo.InstrumentPanelVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.monitor.common.annotation.Log;
import com.monitor.common.core.controller.BaseController;
import com.monitor.common.core.domain.AjaxResult;
import com.monitor.common.enums.BusinessType;
import com.monitor.system.domain.InstrumentPanel;
import com.monitor.system.service.IInstrumentPanelService;
import com.monitor.common.utils.poi.ExcelUtil;
import com.monitor.common.core.page.TableDataInfo;

/**
 * 仪盘Controller
 * 
 * @author monitor
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/system/panel")
public class InstrumentPanelController extends BaseController
{
    @Autowired
    private IInstrumentPanelService instrumentPanelService;

    /**
     * 查询仪盘列表
     */
    @ApiOperation("查询仪盘列表")
    @PreAuthorize("@ss.hasPermi('system:panel:list')")
    @GetMapping("/list")
    public TableDataInfo list(InstrumentPanel instrumentPanel)
    {
        startPage();
        List<InstrumentPanel> list = instrumentPanelService.selectInstrumentPanelList(instrumentPanel);
        return getDataTable(list);
    }

    /**
     * 导出仪盘列表
     */
    @ApiOperation("导出仪盘列表")
    @PreAuthorize("@ss.hasPermi('system:panel:export')")
    @Log(title = "仪盘", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InstrumentPanel instrumentPanel)
    {
        List<InstrumentPanel> list = instrumentPanelService.selectInstrumentPanelList(instrumentPanel);
        ExcelUtil<InstrumentPanel> util = new ExcelUtil<InstrumentPanel>(InstrumentPanel.class);
        util.exportExcel(response, list, "仪盘数据");
    }

    /**
     * 获取仪盘详细信息
     */
    @ApiOperation("获取仪盘详细信息")
    @PreAuthorize("@ss.hasPermi('system:panel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(instrumentPanelService.selectInstrumentPanelById(id));
    }

    /**
     * 新增仪盘
     */
    @ApiOperation("新增仪盘")
    @PreAuthorize("@ss.hasPermi('system:panel:add')")
    @Log(title = "仪盘", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InstrumentPanel instrumentPanel)
    {
        return toAjax(instrumentPanelService.insertInstrumentPanel(instrumentPanel));
    }

    /**
     * 修改仪盘
     */
    @ApiOperation("修改仪盘")
    @PreAuthorize("@ss.hasPermi('system:panel:edit')")
    @Log(title = "仪盘", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InstrumentPanel instrumentPanel)
    {
        return toAjax(instrumentPanelService.updateInstrumentPanel(instrumentPanel));
    }

    /**
     * 删除仪盘
     */
    @ApiOperation("删除仪盘")
    @PreAuthorize("@ss.hasPermi('system:panel:remove')")
    @Log(title = "仪盘", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(instrumentPanelService.deleteInstrumentPanelByIds(ids));
    }

    /**
     * 查询仪盘列表
     */
    @ApiOperation("查询当日正常仪盘列表")
    @GetMapping("/currentNormalList")
    public TableDataInfo currentNormalList(InstrumentPanelVo instrumentPanelVo)
    {
        startPage();
        List<InstrumentPanelVo> list = instrumentPanelService.selectInstrumentPanelCurrentNormalList(instrumentPanelVo);
        return getDataTable(list);
    }

    /**
     * 查询仪盘列表
     */
    @ApiOperation("查询历史正常仪盘列表")
    @GetMapping("/normalList")
    public TableDataInfo normalList(InstrumentPanelVo instrumentPanelVo)
    {
        startPage();
        List<InstrumentPanelVo> list = instrumentPanelService.selectInstrumentPanelNormalList(instrumentPanelVo);
        return getDataTable(list);
    }

    /**
     * 查询仪盘列表
     */
    @ApiOperation("查询当日异常仪盘列表")
    @GetMapping("/currentAbnormalList")
    public TableDataInfo currentAbnormalList(InstrumentPanelVo instrumentPanelVo)
    {
        startPage();
        List<InstrumentPanelVo> list = instrumentPanelService.selectInstrumentPanelCurrentAbnormalList(instrumentPanelVo);
        return getDataTable(list);
    }

    /**
     * 查询仪盘列表
     */
    @ApiOperation("查询历史异常仪盘列表")
    @GetMapping("/abnormalList")
    public TableDataInfo abnormalList(InstrumentPanelVo instrumentPanelVo)
    {
        startPage();
        List<InstrumentPanelVo> list = instrumentPanelService.selectInstrumentPanelAbnormalList(instrumentPanelVo);
        return getDataTable(list);
    }
}
